var Queue = (function () {
  var _item = new WeakMap();

  function PriorityElement(name, priority) {
    this.name = name;
    this.priority = priority;
  }
  return class Queue {
    constructor() {
      _item.set(this, []);
    }
    enqueue(elem, priority) {
      const priorityElement = new PriorityElement(elem, priority);
      let flag = false;
      for (let i = 0; i < _item.get(this).length; i++) {
        if (priorityElement.priority < _item.get(this)[i].priority) {
          _item.get(this).splice(i, 0, priorityElement);
          flag = true;
          break;
        }
      }
      if (!flag) {
        _item.get(this).push(priorityElement);
      }
    }
    dequeue() {
      _item.get(this).shift();
    }
    isEmpty() {
      return _item.get(this).length === 0;
    }
    toString() {
      return _item.get(this);
    }
  };
})();
const q = new Queue();
q.enqueue("王五", 4);
q.enqueue("张三", 5);
q.enqueue("赵六", 1);
q.enqueue("李四", 3);


console.log(q.toString());
